A pattern matcher for miniKanren or How to get into trouble with CPS macros

نویسندگان

  • Andrew W. Keep
  • Michael D. Adams
  • Lindsey Kuper
  • William E. Byrd
  • Daniel P. Friedman
چکیده

CPS macros written using Scheme’s syntax-rules macro system allow for guaranteed composition of macros and control over the order of macro expansion. We identify a limitation of CPS macros when used to generate bindings from a non-unique list of user-specified identifiers. Implementing a pattern matcher for the miniKanren relational programming language revealed this limitation. Identifiers come from the pattern, and repetition indicates that the same variable binding should be used. Using a CPS macro, binding is delayed until after the comparisons are performed. This may cause free identifiers that are symbolically equal to be conflated, even when they are introduced by different parts of the source program. After expansion, this leaves some identifiers unbound that should be bound. In our first solution, we use syntax-case with bound-identifier=? to correctly compare the delayed bindings. Our second solution uses eager binding with syntax-rules. This requires abandoning the CPS approach when discovering new identifiers.

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

منابع مشابه

Lecture Notes on Dynamical Systems & Dynamic Axioms

Lecture 4 on Safety & Contracts demonstrated how useful and crucial CPS contracts are for CPS. Their role and understanding goes beyond dynamic testing, though. In CPS, proven CPS contracts are infinitely more valuable than dynamically tested contracts, because dynamical tests of contracts at runtime of a CPS generally leave open very little flexibility for reacting to them in any safe way. Aft...

متن کامل

Extensible Pattern Matching in an Extensible Language

Pattern matching is a widely used technique in functional languages, especially those in the ML and Haskell traditions. Although pattern matching is typically not built into languages in the Lisp tradition, it is often available via libraries built with macros. We present a sophisticated pattern matcher for Racket, which extends the language using macros, supports novel and widelyuseful pattern...

متن کامل

Image processing using miniKanren

An integral image is one of the most efficient optimization technique for image processing. However an integral image is only a special case of delayed stream or memoization. This research discusses generalizing concept of integral image optimization technique, and how to generate an integral image optimized program code automatically from abstracted image processing algorithm. In oder to abstr...

متن کامل

Teacher Wait-Time and Learner Initiation: A Single Case Analysis

The prevailing pattern of classroom interaction is a tripartite exchange structure known as IRF (teacher initiation, student response, teacher follow-up/feedback; Sinclair & Coulthard, 1975). Although it has its own contributions to classroom discourse, it has been criticized on several grounds, particularly for affording minimum learner participation opportunities (Kasper, 2001). An alternativ...

متن کامل

Partial Evaluation of Pattern Matching in StringsCharles

This article describes how automatically specializing a fairly naive pattern matcher by partial evaluation leads to the Knuth, Morris & Pratt algorithm. Interestingly enough, no theorem proving is needed to achieve the partial evaluation, as was previously argued, and it is suucient to identify a static component in the computation to get the result { a deterministic nite automaton. This experi...

متن کامل

ذخیره در منابع من


  با ذخیره ی این منبع در منابع من، دسترسی به آن را برای استفاده های بعدی آسان تر کنید

برای دانلود متن کامل این مقاله و بیش از 32 میلیون مقاله دیگر ابتدا ثبت نام کنید

ثبت نام

اگر عضو سایت هستید لطفا وارد حساب کاربری خود شوید

عنوان ژورنال:

دوره   شماره 

صفحات  -

تاریخ انتشار 2009